var registerpasswordOK=false;
var registerusernameOK=false;
var registercaptchaOK=false;
var registerpasswordconfirmOK=false;

function verifyregister(){
	isregisterPassword(RegisterUsername.value);
	isregisterUsername(RegisterPassword.value);
	isregisterCaptcha(RegisterCaptcha.value);
	isregisterPasswordconfirm(RegisterPasswordCheck.value);
	return(registerpasswordOK && registerusernameOK && registercaptchaOK && registerpasswordconfirmOK);
}



function isregisterPassword(s) 
{ 
	registerpasswordOK=false;
	var input=s.trim();
	var patrn=/^(\w){6,16}$/; 
	var patrndigit=/^(\d){6,16}$/;
	if(input.length==0){checkregisterpassword.innerHTML="请输入密码"; $("#checkregisterpassword").show();}
	else if(input.length<6) {checkregisterpassword.innerHTML="密码过短，要求长度大于5"; $("#checkregisterpassword").show();}
	else if(input.length>16) {checkregisterpassword.innerHTML="密码过长，要求长度小于17";$("#checkregisterpassword").show();}
	else if (!patrn.exec(input)){checkregisterpassword.innerHTML="密码不允许包含大小写字母、数字和下划线以外的字符";$("#checkregisterpassword").show();}
	else if(!patrndigit.exec(input)) {
		$("#checkregisterpassword").hide();
		registerpasswordOK=true;
	}
	else {
		checkregisterpassword.innerHTML="不能为纯数字";
		$("#checkregisterpassword").show();
	}
}

function isregisterUsername(s) 
{ 
	registerusernameOK=false;
	var input=s.trim();
	var patrn=/^[a-zA-Z][a-zA-Z0-9_]{0,15}$/; 
	var patrn2=/^(\w){1,16}$/; 
	if(input.length==0){checkregisterusername.innerHTML="请输入用户名"; $("#checkregisterusername").show();}
	else if(input.length>16) {checkregisterusername.innerHTML="用户名过长，要求长度小于17";$("#checkregisterusername").show();}
	else if (!patrn2.exec(input)){checkregisterusername.innerHTML="用户名不允许包含大小写字母、数字和下划线以外的字符";$("#checkregisterusername").show();}
	else if(!patrn.exec(input)) {
		checkregisterusername.innerHTML="用户名的第一个字符不能为下划线或数字";
		$("#checkregisterusername").show();
	}
	else {
		$("#checkregisterusername").hide();
		registerusernameOK=true;
	}
}


function isregisterPasswordconfirm(s){
	registerpasswordconfirmOK=false;
	var confirm=s.trim();
	var password=RegisterPassword.value.trim();
	if(confirm==password){
		$("#checkregisterpasswordconfirm").hide();
		registerpasswordconfirmOK=true;
	}
	else{
		checkregisterpasswordconfirm.innerHTML="密码与确认密码不一致";
		$("#checkregisterpasswordconfirm").show();
	}
}

function isregisterCaptcha(s){
	registercaptchaOK=false;
	var input=s.trim();
	var patrn=/^(\d){4,4}$/;
	if(input.length==0){
		checkregistercaptcha.innerHTML="请输入验证码";
		$("#checkregistercaptcha").show();
	}
	else if(!patrn.exec(input)) {
		checkregistercaptcha.innerHTML="验证码为4位数字";
		$("#checkregistercaptcha").show();
	}
	else{
		$("#checkregistercaptcha").hide();
		registercaptchaOK=true;
	}
}